<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include page="forumNavi.jsp"></jsp:include>
<c:if test="${empty post}">
	<script type="text/javascript">
		$(function() {
			setTimeout(function() {
				window.location = 'index.do';
			}, 3000);
		});
	</script>
	<div class='autojump'>
		帖子不存在或已删除<br /> <a href='index.do'>如果您的浏览器没有自动跳转，请点击此链接</a>
	</div>
</c:if>
<c:if test="${!empty post}">
	<script>
	$(function(){
		function replySubmitForm_success(data) {
			if (data.state == 'success') {
				window.location.reload();
			} else {
				alert('回复失败');
			}
		}
	
		$('#replySubmitForm').ajaxForm({
			success : replySubmitForm_success
		});
		
		var clip = new ZeroClipboard.Client();
		clip.setHandCursor(true);
		clip.setCSSEffects(true);
		clip.setText(window.location.href);
		clip.glue("copyTitle");
		clip.addEventListener("complete", function(){
		    alert("复制成功！");
		});
		
		$(window).resize(function(){
		    clip.reposition();
		});
	});
	
	function onlyShowUser(user_id){
		if(window.location.href.indexOf("uid=")>-1){
			window.location.href = window.location.href.replace(/(uid\s*=[\s]*)([^\s\&]+)/g,"$1" + user_id);
		}else{
			window.location.href += ("&uid="+user_id);
		}
	}
	
	function showAllUser(){
		if(window.location.href.indexOf("uid=")>-1){
			window.location.href = window.location.href.replace(/(&uid\s*=[\s]*)([^\s\&]+)/g,"");
		}
	}
	
	</script>
	
	<jsp:include page="postPage.jsp">
		<jsp:param value="Top" name="jumpPageInput"/>
	</jsp:include>
	
	<div class="postlist">
		<table class="postlist_table">
			<tr>
				<td class='postlist_left'>查看:<span class="red">${post.view_num}</span>|回复:<span class="red">${post.reply_num}</span></td>
				<td class='postlist_right'><span class='post_title'>${post.title}</span><span class="copyClip"><a href="javascript:;" id="copyTitle">[复制链接]</a></span></td>
			</tr>
			<c:forEach var="reply" items="${replyList}">
				<tr>
					<td class='postlist_left_split'></td>
					<td class='postlist_right_right'></td>
				</tr>
				<tr>
					<td class='postlist_left'>
						<div class='postcontent_left_head'>${reply.user_name}</div>
					</td>
					<td class='postlist_right'>
						<div class='postcontent_left_head'>
							<img src="css/images/online_member.gif">
							<span class='onlineUserName'>发表于${reply.time_readable}</span>
							<c:if test="${empty param.uid}">
								<c:if test="${reply.user_name != '匿名用户'}">
									<span class="pipe">|</span>
									<span class='onlineUserName'>
										<a href="javascript:;" onclick="onlyShowUser('${reply.user_id}');">只看该作者</a>
									</span>
								</c:if>
							</c:if>
							<c:if test="${!empty param.uid}">
								<span class="pipe">|</span>
								<span class='onlineUserName'>
									<a href="javascript:;" onclick="showAllUser();">显示全部楼层</a>
								</span>
							</c:if>
							
						</div>
					</td>
				</tr>
				<tr>
					<td class='postlist_left'>
						<div class='post_avatar'>
							<img src='login/loggedin_avatar.do?size=middle'/>
						</div>
						<div>
							<span class="post_user_stat">0<br/>主题</span>
							<span class="post_user_stat">0<br/>好友</span>
							<span class="post_user_stat2">0<br/>积分</span>
						</div>
						<div class="post_user_role">
							用户角色
						</div>
						<div class="post_user_level">
							<img src="css/images/star_level3.gif"/><img src="css/images/star_level2.gif"/><img src="css/images/star_level1.gif"/>
						</div>
						<div class="post_user_msg">
							<a href="javascript:;" class="post_user_msg_btn">发消息</a>
						</div>
					</td>
					<td class='postlist_right replyContent'>${reply.content}</td>
				</tr>
				<tr>
					<td class='postlist_left'></td>
					<td class='postlist_right'>
						<div class='postcontent_left_foot'>
							<a href="javascript:;" class="post_reply_btn">回复</a>
						</div>
					</td>
				</tr>
			</c:forEach>
		</table>
	</div>
	
	<jsp:include page="postPage.jsp">
		<jsp:param value="Bottom" name="jumpPageInput"/>
	</jsp:include>
	
	<div class="reply_div">
		<table class="postlist_table">
			<tr>
				<td class='postlist_left'>
					<div class='post_avatar'>
						<img src='login/loggedin_avatar.do?size=middle'/>
					</div>
				</td>
				<td class='postlist_right replySubmitContent'>
					<form id="replySubmitForm" name="replySubmitForm" action="forum/replyNew.do" method="post">
						<input id="replyPostId" name="replyPostId" type="hidden" value="${param.id}"/>
						<input id="replyContent" name="replyContent"/><br/>
						<button class="register_button" onclick="$('#replySubmitForm').submit();return false;">发表回复</button>
					</form>
				</td>
			</tr>
		</table>
	</div>
</c:if>